import request, { $request }/*, { $http as http }*/ from '@/utils/request';
import { formatParams } from '@/utils'
import api from '@/api'

/**
 * 角色信息
 */
export const getOne = async (params) => {
  return request(api.role_get, {
    params,
  });
}

/**
 * 角色列表
 */
export const getList = async (data) => {
  const params = formatParams(data);
  return request(api.role_list, {
    params,
  });
}

/**
 * 删除角色
 */
export const deleteRows = async (data) => {
    return request.post(api.role_remove, {
        data,
    });
}

/**
 * 验证角色名称
 */
export const check = async (params) => {
    // return http.post(api.role_name_valid, {
    //     data,
    //     type: true,
    //     requestType: 'form'
    // });
    return $request(api.role_name_valid, {
      params,
    })
}

/**
 * 所有角色集合（不带分页）
 */
export const getAll = async () => {
  return request(api.role_all);
}

/**
 * 角色绑定的资源列表
 */
export const getAuthList = async (data) => {
  const params = formatParams(data);
  return request(api.role_auth_list, {
    params,
  });
}

/**
 * 删除角色绑定的资源
 */
export const deleteAuths = async (data) => {
    return request.post(api.group_role_remove, {
        data,
    });
}

/**
 * 角色绑定的用户列表
 */
export const getUserList = async (data) => {
  const params = formatParams(data);
  return request(api.role_user_list, {
    params,
  });
}